package com.skycode7.util;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBconnection {
    private String FileName;
    private int DBTyoe;
    private Connection conn;
    private String MySQLDriver;
    private String MySQLURL;
    public DBconnection(){
        conn = null;
    }
    public  Connection getConn() {
        DBTyoe =1;
        switch (DBTyoe){
            case 1:
                return (getConnToMySql());
            default: return null;
        }
    }
    public Connection getConnToMySql(){
        try{
            // 8.0加.cj 小于5.7不加
            MySQLDriver = "com.mysql.cj.jdbc.Driver";
            MySQLURL =
                    "jdbc:mysql://localhost:3306/sky?user=root&password=mysql123456"+
                            "&Unicode=true&characterEncoding=utf8";
            Class.forName(MySQLDriver).newInstance();
            conn = DriverManager.getConnection(MySQLURL);
        }catch (Exception e){
            e.printStackTrace();
        }
        return conn;
    }
}
